package ynu.edu.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import ynu.edu.entities.BaseResponse;
import ynu.edu.entities.Order;
import ynu.edu.feign.fallback.OrderServiceFallback;

/**
 * 订单服务Feign客户端
 */
@FeignClient(name = "order-service", fallback = OrderServiceFallback.class)
public interface OrderServiceClient {
    
    /**
     * 根据订单ID查询订单
     *
     * @param orderId 订单ID
     * @return 订单信息
     */
    @GetMapping("/order/{orderId}")
    BaseResponse<Order> getOrderById(@PathVariable("orderId") Integer orderId);
    
    /**
     * 更新订单状态 - PUT方法
     *
     * @param orderId 订单ID
     * @param orderState 订单状态
     * @return 更新结果
     */
    @PutMapping("/order/status/{orderId}/{orderState}")
    BaseResponse<Void> updateOrderState(@PathVariable("orderId") Integer orderId, 
                                       @PathVariable("orderState") Integer orderState);
    
    /**
     * 更新订单状态 - POST方法（兼容订单服务的POST接口）
     *
     * @param orderId 订单ID
     * @param orderState 订单状态
     * @return 更新结果
     */
    @PostMapping("/order/state")
    BaseResponse<Void> updateOrderStatePost(@RequestParam("orderId") Integer orderId, 
                                          @RequestParam("orderState") Integer orderState);
} 